{% extends 'base.html' %}

{% block body %}
    <div class="fly-panel fly-column">
        <div class="layui-container">
            <ul class="layui-clear">
                <li class="layui-hide-xs {% if is_index %}layui-this{% endif %}"><a href="/">综合</a></li>
                {% for item in catalogs %}
                    <li class="layui-hide-xs" data-catalog="{{ item.pk }}"><a
                            href="{% url 'catalog' item.pk %}">{{ item.name }}</a></li>
                {% endfor %}

                <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li>
                {% if request.user.is_authenticated %}
                    <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a
                            href="{% url 'user_posts' %}">我发表的贴</a></li>
                    <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a
                            href="{% url 'user_posts' %}#collection">我收藏的贴</a></li>
                {% endif %}

            </ul>

            <div class="fly-column-right layui-hide-xs">
                <span class="fly-search"><i class="layui-icon"></i></span>
                <a href="{% url 'add_post' %}" class="layui-btn">发表新帖</a>
            </div>
            <div class="layui-hide-sm layui-show-xs-block"
                 style="margin-top: -10px; padding-bottom: 10px; text-align: center;">
                <a href="{% url 'add_post' %}" class="layui-btn">发表新帖</a>
            </div>
        </div>
    </div>

    <div class="layui-container">
        <div class="layui-row layui-col-space15">

            {% block content %}
            {% endblock %}
            <div class="layui-col-md4">

                {% if is_index %}
                    <div class="fly-panel">
                        <h3 class="fly-panel-title">温馨通道</h3>
                        <ul class="fly-panel-main fly-list-static">
                            {% for item in passageways %}
                                <li>
                                    <a href="{{ item.url }}" target="_blank">{{ item.name }}</a>
                                </li>
                            {% endfor %}
                        </ul>
                    </div>

                    {% if request.user.is_authenticated %}
                        <div class="fly-panel fly-signin">
                            <div class="fly-panel-title">
                                签到
                                <i class="fly-mid"></i>
                                <a href="javascript:;" class="fly-link" id="LAY_signinHelp">说明</a>
                            </div>
                            <div class="fly-panel-main fly-signin-main">

                            </div>
                        </div>
                    {% endif %}


                    <div class="fly-panel">
                        <div class="fly-panel-title">
                            友情赞助
                        </div>
                        <div class="fly-panel-main">
                            {% for item in ads %}
                                <a href="{{ item.url }}" target="_blank" class="fly-zanzhu"
                                   style="background-color: {{ item.color|safe|default:'#5FB878' }};">{{ item.name }}</a>
                            {% endfor %}

                        </div>
                    </div>

                    <div class="fly-panel fly-rank fly-rank-reply" id="LAY_replyRank">
                        <h3 class="fly-panel-title">回帖榜</h3>
                        <dl>
                            <!--<i class="layui-icon fly-loading">&#xe63d;</i>-->
                            {% for item in users_info %}
                                <dd>
                                    <a href="/user/{{ item.pk }}">
                                        <img src="{{ item.avatar.url }}"><cite>{{ item.user.username }}</cite><i>
                                        {{ item.reply_count|default:0 }}次回答</i>
                                    </a>
                                </dd>
                            {% empty %}
                                <div class="fly-none">没有相关数据</div>
                            {% endfor %}
                        </dl>
                    </div>
                {% endif %}


                <dl class="fly-panel fly-list-one">
                    <dt class="fly-panel-title">本周热议</dt>
                    {% for item in hot_posts %}
                        <dd>
                            <a href="/post/{{ item.pk }}">{{ item.title }}</a>
                            <span><i class="iconfont icon-pinglun1"></i> {{ item.comment_count|default:0 }}</span>
                        </dd>
                    {% empty %}
                        <div class="fly-none">没有相关数据</div>
                    {% endfor %}
                </dl>

                <div class="fly-panel fly-link">
                    <h3 class="fly-panel-title">友情链接</h3>
                    <dl class="fly-panel-main">
                        {% for item in friend_links %}
                            <dd><a href="{{ item.url }}" target="_blank">{{ item.name }}</a></dd>
                        {% endfor %}
                        <dd><a href="mailto:{{ bbs_option.email }}?subject=%E7%94%B3%E8%AF%B7Fly%E7%A4%BE%E5%8C%BA%E5%8F%8B%E9%93%BE"
                               class="fly-link">申请友链</a>
                        <dd>
                    </dl>
                </div>

            </div>
        </div>
    </div>
{% endblock %}

{% block other_js %}
    {% if catalog_id %}
        <script>
        $("li[data-catalog={{ catalog_id }}]").addClass("layui-this");
        </script>
    {% endif %}
{% endblock %}